#ifndef ENTITYMANAGER_H
#define ENTITYMANAGER_H

#include "entity.h"
#include "tower.h"
#include "unit.h"
#include "unitemitter.h"
#include <QHash>

class Game;

class EntityManager
{
public:
   EntityManager();
   ~EntityManager();

   Entity::EntityListType listByType(ENTITY_TYPE type=ENTITY_ANY);
   Entity* closest(const QVector2D &position, ENTITY_TYPE type=ENTITY_ANY);
   Entity* addEntity(const quint32 playerID, const EntityBaseStats &stats);
   bool addEntity(Entity *entity);
   Entity::EntityListType addEntitySquad(const quint32 playerID, const quint32 squadID, const EntityBaseStats &stats, quint32 squadSize);
   void addEntitySquad(const EntitySquadType &squad);
   void removeEntity(qint32 id);
   void removeInactiveEntities();
   Entity* entityFromID(const qint32 id);
   void setGame(Game *game);
   quint32 uniqueSquadID();

   void tick(const qreal timeDelta);

protected:
   Entity::EntityMapType mEntities;
   qint32 mIDCounter;
   quint32 mSquadIDCounter;
   Game *mGame;
   typedef QHash<quint32,quint32> SquadSizeHashType;
   SquadSizeHashType mSquadSizes;
};

#endif // ENTITYMANAGER_H
